//
//  messageNotiHeadView.swift
//  LeDian
//
//  Created by 三秒文化 on 16/3/17.
//  Copyright © 2016年 51ledian. All rights reserved.
//

import UIKit

class LDMessageNotiHeadView: UIView {
    
    var notiImageView = UIImageView()
    var notiTitleLab = UILabel()
    var notiContentLab = UILabel()
    
    var bossLab:UILabel?
    var tapClosure:(()->Void)?
    
    
    var imgW:CGFloat = 46
    lazy var gapView:UIView = {
        
        let views = UIView()
        views.backgroundColor = LDGolbalColor.White
        return views
    }()
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setDefaultContent()
        setupFrame()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setDefaultContent() {
        
        backgroundColor = LDGolbalColor.BgGoundGray
        
        
        notiImageView = UIImageView.setImageView(imgW/2)
        notiImageView.image = UIImage.init(named: "message_notification.png")
        
        notiTitleLab = UILabel.setDetailsLab("通知", fontSize: 14, titleColor: LDFontColor.Black,Alignment: nil)
        
        notiContentLab = UILabel.setDetailsLab("0个人看过您,0个新职位", fontSize: 12, titleColor: LDFontColor.Orange,Alignment: nil)
        bossLab = UILabel.setDetailsLab("最近联系的BOSS", fontSize: 12, titleColor: LDFontColor.Green, Alignment: .Left)
        
        gapView.userInteractionEnabled = true
        gapView.bk_whenTapped { [weak self] in
            if self?.tapClosure != nil {
                self?.tapClosure!()
            }
        }
        
        addSubview(gapView)
        gapView.addSubview(notiImageView)
        gapView.addSubview(notiTitleLab)
        gapView.addSubview(notiContentLab)
        gapView.addSubview(bossLab!)
    }
    func tapHeadView(closure:(()->Void)) {
        tapClosure = closure
    }
    //** Auto 布局 */
    func setupFrame() {
        
        gapView.snp_makeConstraints { (make) in
            
            make.top.equalTo(LDMargin_V*2)
            make.height.equalTo(60)
            make.left.right.equalTo(0)
        }
        
        notiImageView.snp_makeConstraints(closure: { (make) in
            
            make.centerY.equalTo(gapView)
            make.left.equalTo(LDMargin_V * 3)
            make.width.height.equalTo(imgW)
        })
        
        notiTitleLab.snp_makeConstraints { (make) in
            
            make.top.equalTo(notiImageView).offset(LDMargin_V*1.5)
            make.left.equalTo(notiImageView.snp_right).offset(Margin_V*2)
            make.width.equalTo(180)
            make.height.equalTo(13)
        }
        
        notiContentLab.snp_makeConstraints { (make) in
            
            make.top.equalTo(notiTitleLab.snp_bottom).offset(LDMargin_V)
            make.left.equalTo(notiTitleLab)
            make.height.equalTo(13)
            make.width.equalTo(220)
        }
        
        bossLab?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(gapView.snp_bottom).offset(LDMargin_V*3)
            make.left.equalTo(notiImageView)
            make.height.equalTo(15)
        })
    }
    
}
